/**

* <p>Title: GoodsController.java</p>

* <p>Description: </p>

* <p>Copyright: Copyright (c) 2021</p>

* <p>Company: www.chinasofti.com</p>

* @author knowno

* @date 2021年3月9日

* @version 1.0

*/
package com.etc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.etc.entity.Goods;
import com.etc.entity.Goodstype;
import com.etc.util.AjaxResponse;
import com.etc.zmall.service.GoodsService;
import com.etc.zmall.service.GoodsTypeService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 
 * <p>
 * Title: GoodsController
 * </p>
 * 
 * <p>
 * Description:
 * </p>
 * 
 * @author knowno
 * 
 * @date 2021年3月9日
 * 
 */
@RestController
@Api(value = "商品类型的控制器接口", description = "商品类型控制器，实现了商品类型的检索，增加，修改和删除等操作")
public class GoodsTypeController {

	@Autowired
	private GoodsTypeService goodsTypeService;

	/**
	 * 
	 * 
	 * <p>
	 * Title: listGoods
	 * </p>
	 * 
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param keywords
	 * @param page
	 * @param limit
	 * @return
	 */
	@GetMapping("api/goodstype")
	@ApiOperation(value = "商品类型检索", notes = "实现模糊查询加分页", httpMethod = "GET", response = AjaxResponse.class)
	public AjaxResponse<Goodstype> listGoodsType(
			@ApiParam(name = "keywords", required = false, value = "商品类型查询关键字") @RequestParam(value = "keywords", required = false, defaultValue = "") String keywords,
			@RequestParam(value = "page", required = false, defaultValue = "1") int page,
			@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {

		// 调用业务层方法实现分页查询
		PageInfo<Goodstype> pageinfo = goodsTypeService.selGoodsTypeBypage(page, limit, keywords);
		// 将返回结果转换为视图层能接受的数据格式，AjaxResponse=>Layui所以自己封装了一个对象
		AjaxResponse<Goodstype> ar = new AjaxResponse<Goodstype>(0, "success", (int) pageinfo.getTotal(),
				pageinfo.getList());

		return ar;
	}

}
